<template>
    <el-cascader placeholder="请选择网格"
    :show-all-levels="false"
    :options="options"
    v-model="value"
    :filterable="true"
    @change="changeValue" />
</template>

<script>
import {getOptionDataType} from '@/utils/region'
import {getUserGridTree} from '@/utils/SessionDataUtil'
export default {
  props: {
    gridId: String,
    gridTree: Array
  },
  data () {
    return {
      options: [],
      value: []
    }
  },
  components: {},
  mounted () {
    this.getOptions()
  },
  methods: {
    getOptions () {
      let gridTree = getUserGridTree()
      if (gridTree && gridTree instanceof Array) {
        this.options = getOptionDataType(gridTree[0].children)
      }
    },
    changeValue () {
      if (this.value && this.value instanceof Array) {
        let len = this.value.length
        console.log(this.value)
        this.$emit('input', this.value[len - 1])
      }
    }
  }
}
</script>
